package com.github.postsanf.yinian.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.RelativeLayout;

import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.utils.SpUtils;
import com.github.postsanf.yinian.utils.UIHelper;
import com.umeng.analytics.MobclickAgent;

public class AlbumFuliDialogActivity extends Activity implements View.OnClickListener {
    private RelativeLayout dialog_mynotice;
    private RelativeLayout rl_mynotice;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_dialog_album_fuli);
        initView();
    }

    private void initView() {
        dialog_mynotice = (RelativeLayout) findViewById(R.id.dialog_mynotice);
        dialog_mynotice.setOnClickListener(this);
        rl_mynotice= (RelativeLayout) findViewById(R.id.rl_mynotice);
        findViewById(R.id.fuli_dialogclose).setOnClickListener(this);
        findViewById(R.id.fuli_dialog_btn).setOnClickListener(this);
        Animation translateAnimationf = new TranslateAnimation(0, 0, -UIHelper.dip2px(this, 220), 0);
        translateAnimationf.setDuration(400);
        rl_mynotice.startAnimation(translateAnimationf);
    }


    @Override
    public void onBackPressed() {

    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.fuli_dialogclose:
                dialog_mynotice.setClickable(false);
                Animation translateAnimationf = new TranslateAnimation(0, 0, 0, UIHelper.dip2px(AlbumFuliDialogActivity.this, 600));
                translateAnimationf.setDuration(500);
                rl_mynotice.startAnimation(translateAnimationf);
                translateAnimationf.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        rl_mynotice.setVisibility(View.GONE);
                        finish();
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }
                });
                break;
            case R.id.fuli_dialog_btn:
                startActivity(new Intent(this, AwardActivity.class));
                finish();
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        SpUtils.put(this, "isKuoRongShow", true);
    }

    // 友盟统计
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart(this.getClass().getSimpleName());
        MobclickAgent.onResume(this);
    }

    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd(this.getClass().getSimpleName());
        MobclickAgent.onPause(this);
    }

}
